package com.ruoyi.ruoyixingyue.modules.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.ConvertUtils;
import com.ruoyi.ruoyixingyue.modules.api.entity.CourseType;
import com.ruoyi.ruoyixingyue.modules.api.mapper.CourseTypeMapper;
import com.ruoyi.ruoyixingyue.modules.api.po.CourseTypeDictPo;
import com.ruoyi.ruoyixingyue.modules.api.service.ICourseTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lzz
 * @since 2024-02-14
 */
@Service
public class CourseTypeServiceImpl extends ServiceImpl<CourseTypeMapper, CourseType> implements ICourseTypeService {


    @Override
    public R<List<CourseType>> courseTypeListAPI_001() {
        QueryWrapper<CourseType> queryWrapper = new QueryWrapper<>();
        List<CourseType> courseTypeList = this.list(queryWrapper.lambda().eq(CourseType::getStatus, 0));
        return R.ok(courseTypeList);
    }

    @Override
    public R<List<CourseTypeDictPo>> courseTypeDictAPI_002() {
        QueryWrapper<CourseType> queryWrapper = new QueryWrapper<>();
        List<CourseType> courseTypeList = this.list(queryWrapper);
        List<CourseTypeDictPo> source = ConvertUtils.sourceToTarget(courseTypeList, CourseTypeDictPo.class);
        return R.ok(source,"课程类型字典接口调用成功");
    }
}
